CMAKE_MINIMUM_REQUIRED(VERSION 2.8)


#project name
PROJECT(ifcgears C CXX)

#set output locations
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

#set some default variables
set(CMAKE_USE_RELATIVE_PATHS FALSE)
set(CMAKE_SUPPRESS_REGENERATION TRUE)
SET(CMAKE_DEBUG_POSTFIX "d")

# options
OPTION(OPT_VIEWER "build the IfcGearsViewer. if set to false only the ifcgears.lib will be built" FALSE)
OPTION(OPT_OpenMP_PARALLEL "use OpenMP to parallelize IFCGEARS." TRUE)

SET(ENV_PATH $ENV{PATH})
#FILE(TO_CMAKE_PATH	${ENV_PATH}	ENV_PATH)

# in case of unix os, find eclipse executable
IF(UNIX)
  FIND_PROGRAM(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse PATHS ${ENV_PATH} DOC "The Eclipse executable")
ENDIF(UNIX)

#Require additional packages
IF (OPT_OpenMP_PARALLEL)
  FIND_PACKAGE(OpenMP REQUIRED)
ENDIF (OPT_OpenMP_PARALLEL)


#add compiler flags required for OpenMP
IF(OPENMP_FOUND AND OPT_OpenMP_PARALLEL )
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  ADD_DEFINITIONS(-DIFCGEARS_OPENMP)
ENDIF(OPENMP_FOUND AND OPT_OpenMP_PARALLEL)


#add source directory
ADD_SUBDIRECTORY(IfcGears)
 

IF (OPT_VIEWER)
 #Require additional packages
 FIND_PACKAGE(Qt4 REQUIRED)

 IF(NOT OPENSCENEGRAPH_FOUND)
	FIND_PACKAGE(OpenSceneGraph REQUIRED osgDB osgUtil osgGA osgFX osgSim osgViewer osgText)
	# osgQt is unfortunately not in the OpenSceneGraph find module yet... add it manually
	
 ENDIF(NOT OPENSCENEGRAPH_FOUND)
 
 ADD_SUBDIRECTORY(IfcGears2Osg) 

 ADD_SUBDIRECTORY(IfcGearsViewer)
ENDIF (OPT_VIEWER)
